package com.neu.json;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.neu.entity.TBUser;

public class jsonDemo02 {
public static void method() {
	JSONObject json = new JSONObject();
	json.put("id", 1);
	json.put("username", "张三");
	json.put("userpass", "123");
	TBUser tu = JSON.toJavaObject(json, TBUser.class);
	System.out.println(tu);
}
public static void method01() {
	TBUser tb = new TBUser(0, "李四", "123321");
	TBUser tb1 = new TBUser(1,"老王","963");
	List<TBUser> list = new ArrayList<>();
	list.add(tb);
	list.add(tb1);
	Object ob = JSON.toJSON(list);
	String st = JSON.toJSONString(list);
	System.out.println(ob);
	System.out.println(st);
}
public static void main(String[] args) {
	method();
	method01();
}
}
